package door.utils;

import app.nbdevices.utils.ConvertUtil;
import com.baomidou.mybatisplus.extension.api.R;
import door.modle.codecModle.DoorCmd;
import door.modle.codecModle.DoorReport;
import door.modle.revModle.RevDoorCmdData;
import door.modle.revModle.RevDoorReportData;

public class DoorDecode {
    public static DoorReport doorReportDataDecode(RevDoorReportData revDoorReportData){
        DoorReport doorReport=new DoorReport();
        byte[] res= ConvertUtil.getBase64Codec().decode(revDoorReportData.getReportData());
        byte[] addrId=ConvertUtil.getBase64Codec().decode(revDoorReportData.getAddrId());
        doorReport.setVoltage(res[2]);
        doorReport.setRssi(res[3]);
        doorReport.setM_check(res[11]);
        doorReport.setC_ele(res[13]);
        doorReport.setDev_ele(res[12]);
        doorReport.setAddressField(addrId);
        return doorReport;
    }
    public static DoorCmd doorCmdDecode(RevDoorCmdData revDoorCmdData){
        DoorCmd doorCmd=new DoorCmd();
        byte[] addrId=ConvertUtil.getBase64Codec().decode(revDoorCmdData.getAddrId());
        doorCmd.setAddressField(addrId);
       doorCmd.setIsSuc(revDoorCmdData.getIsSuc());
        return doorCmd;
    }

    public static void main(String[] args) {
        RevDoorReportData revDoorReportData=new RevDoorReportData();
        revDoorReportData.setReportData("AABzDiA4UDYYERgBAAEoQAFTGGBV");
    }
}
